These functions maintain key/content pairs in a data base. The nnnnddddbbbbmmmm
functions will handle very large (a billion blocks) databases and will
access a keyed item in one or two file system accesses. The nnnnddddbbbbmmmm66664444
functions are identical to the nnnnddddbbbbmmmm routines except that they can be used
to operate on databases larger than 2 Gigabytes. This package replaces
the earlier _d_b_m(3B) library, which managed only a single database.
_K_e_ys and _c_o_n_t_e_n_ts are described by the _d_a_t_u_m typedef. A _d_a_t_u_m specifies
a string of _d_s_i_z_e bytes pointed to by _d_p_t_r. Arbitrary binary data, as
well as normal ASCII strings, are allowed. The data base is stored in
two files. One file is a directory containing a bit map and has `.dir'
as its suffix. The second file contains all data and has `.pag' as its
suffix.
Before a database can be accessed, it must be opened by _d_b_m__o_p_e_n. This
will open and/or create the files _f_i_l_e....ddddiiiirrrr and _f_i_l_e....ppppaaaagggg depending on the
flags parameter (see _o_p_e_n(2)).
Once open, the data stored under a key is accessed by _d_b_m__f_e_t_c_h and data
is placed under a key by _d_b_m__s_t_o_r_e. The _f_l_a_g_s field can be either
DDDDBBBBMMMM____IIIINNNNSSSSEEEERRRRTTTT or DDDDBBBBMMMM____RRRREEEEPPPPLLLLAAAACCCCEEEE.... DDDDBBBBMMMM____IIIINNNNSSSSEEEERRRRTTTT will only insert new entries into
the database and will not change an existing entry with the same key.
DDDDBBBBMMMM____RRRREEEEPPPPLLLLAAAACCCCEEEE will replace an existing entry if it has the same key. A key
(and its associated contents) is deleted by _d_b_m__d_e_l_e_t_e. A linear pass
through all keys in a database may be made, in an (apparently) random
order, by use of _d_b_m__f_i_r_s_t_k_e_y and _d_b_m__n_e_x_t_k_e_y. _D_b_m__f_i_r_s_t_k_e_y will return
the first key in the database. _D_b_m__n_e_x_t_k_e_y will return the next key in
the database. The following code will traverse the data base:
for (key = dbm_firstkey(db);
key.dptr != NULL;
key = dbm_nextkey(db))
_D_b_m__e_r_r_o_r returns non-zero when an error has occurred reading or writing
the database. _D_b_m__c_l_e_a_r_e_r_r resets the error condition on the named
database.
DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
All functions that return an _i_n_t indicate errors with negative values. A
zero return indicates ok. Routines that return a _d_a_t_u_m indicate errors
with a null (0) _d_p_t_r. If _d_b_m__s_t_o_r_e called with a _f_l_a_g_s value of
DDDDBBBBMMMM____IIIINNNNSSSSEEEERRRRTTTT finds an existing entry with the same key it returns 1.
Some error conditions will set _e_r_r_n_o. These are: EEEENNNNOOOOMMMMEEEEMMMM:::: runtime memory
allocation failed; EEEEPPPPEEEERRRRMMMM:::: file permissions don't match the process
euid/egid permissions; EEEEIIIINNNNVVVVAAAALLLL:::: key+data sizes for _d_b_m__s_t_o_r_e exceed the
internal block size; EEEEFFFFBBBBIIIIGGGG:::: hash table overflow would cause the maximum